// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueCookie from 'vue-cookie'
import ElementUI from 'element-ui'
import VCharts from 'v-charts'
import Icon from 'vue-awesome/components/Icon'
import OpenUtils from './plugins/open'
import App from './App'
import router from './router'
import store from './store'

import 'element-ui/lib/theme-chalk/index.css'
import './assets/styles/element-reset.scss'
import './assets/styles/default.scss'
import './assets/styles/animation.scss'
import './assets/styles/transition.scss'
import 'vue-awesome/icons'

// todo
// // 自定义指令
// Vue.directive('role', {
//   bind (el, binding, vnode) {
//     // 角色不对，移除 DOM
//     if (binding.value !== 'boss') {
//       el.parentNode.removeChild(el)
//     }
//   }
// })
//
// Vue.directive('perm', {
//   bind (el, binding, vnode) {
//     // 没有权限，移除 DOM
//     if (permUtils.has(binding.value)) {
//       el.parentNode.removeChild(el)
//     }
//   }
// })

Vue.use(VueCookie)
Vue.use(ElementUI)
Vue.use(VCharts)
Vue.use(OpenUtils)

Vue.component('icon', Icon)
// Vue.component(CollapseTransition.name, CollapseTransition)

// Vue.config.debug = true;
// Vue.config.productionTip = false

// // 路由守卫
// router.beforeEach((to, from, next) => {
//   if (to.matched.length > 0) {
//     next()
//   } else {
//     next({path: 'not-found'})
//   }
// })

Vue.directive('focus', {
  // 当绑定元素插入到 DOM 中。

  inserted: function (el) {
    // 聚焦元素
    el.focus()
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  store,
  router,
  template: '<App/>',
  components: { App }
})
